<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1,minimum-scale=1,user-scalable=no" media="(device-height: 568px)">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="HandheldFriendly" content="True">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title></title>
    <link rel="stylesheet" type="text/css" media="all" href="../css/reset.css" />
    <link rel="stylesheet" type="text/css" media="all" href="../css/swiper.min.css" />
    <link rel="stylesheet" type="text/css" media="all" href="../css/style.css" />

    <script type="text/javascript" src="../js/common/jquery-2.1.1.min.js"></script>
    <script src="../js/common/swiper.jquery.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/common/jquery.SuperSlide.2.1.1.js"></script>
    <script src="../js/common/js.js" type="text/javascript"></script>
    <style>
        .androidShow{
            display:none;
        }
        .shList{
            background: #eee;
        }

        .comList:not(:last-of-type){
            border-bottom:1px solid #eee;
        }
    </style>
</head>

<body style="background:white;">
    <!-- 顶部搜索 -->
    <div class="inhetop bgColor padT6">
        <div class="inhetople" style="background:#e6e6e6;">
            <img src="../img/logo.png" alt="" class="logo" />
            <div class="inheinputd">
                <!-- ios点击搜索 -->
                <!-- <form class="inheinput_wrap iosShow" action="">
                    <img src="../img/search.png" alt="" class="inhesearch" />
                    <input type="search" autocomplete="off" class="heinput" placeholder="输入关键字" />
                </form> -->
                <!-- 安卓输入搜索 androidShow-->
                <div class="inheinput_wrap">
                    <img src="../img/search.png" alt="" class="inhesearch" />
                    <input type="text" class="heinput" placeholder="输入关键字" />
                </div>

                <a href="javascript:;" class="inhetoplink close">
                    <img src="../img/close.png" alt="">
                </a>
            </div>
        </div>
        <a href="fox://setBack" class="cancelBtn" style="color:#777">取消</a>
    </div>
    <!-- 搜索结果内容 -->
    <div id="page" class="page padT13_5">
        <div class="searchWrap">
            <!-- 搜索历史 -->
            <div class="searchHistory">
                <div class="shTitle">
                    <span>搜索历史</span>
                    <a class="clearSH" href="javascript:;">清空搜索历史</a>
                </div>
                <div class="shLists searchHistoryLists">
                    <!-- <a href="javascript:;" class="shList">花岗岩</a> -->
                </div>
            </div>
            <!-- 猜你想找的 -->
            <div class="guessYouWant">
                <div class="shTitle">
                    <span>猜你想找的</span>
                </div>
                <div class="shLists search_labels">
                    <!-- <a href="searchResult.html" class="shList">松岛枫松岛枫</a> -->
                </div>
            </div>
        </div>
        <div class="serchResultLists">
            <!-- 商品 -->
            <div class="shopLists">
                <div class="shopTitle goodsTitle">

                </div>
                <div class="ngoods"></div>
            </div>
            <!-- 企业 -->
            <div class="comLists marT20">
                <div class="shopTitle comTitle">

                </div>
                <div class="companyList"></div>
            </div>
        </div>
    </div>

    <!-- 搜索相关结果弹框 -->
    <!-- <div class="searchResult">
        <a href="searchResult.html" class="sItem h88">奥特曼</a>
        <a href="searchResult.html" class="sItem h88">奥特曼灰色</a>
        <a href="searchResult.html" class="sItem h88">奥特曼（岗石）</a>
    </div> -->

    <script src="../js/search.js" type="text/javascript"></script>
    <script>
        getDbDatas();
        // 获取历史搜索
        function getDbDatas() {
            if (isAndroid_ios()) {
                //安卓  
                let datas = window.android.getDbDatas();
                if (datas != '') {
                    datas = eval("(" + datas + ")");
                    let html = '';
                    for (let i = 0; i < datas.length; i++) {
                        let o = datas[i];
                        html += `
                <a href="javascript:;" class="shList">${o}</a>
            `;
                    }
                    $('.searchHistoryLists').html(html);
                } else {
                    return;
                }
            } else {
                //ios
                window.webkit.messageHandlers.getDbDatas.postMessage('');
            }
        }

        // ios获取历史搜索
        function getDbDatacode(str) {
            let html = '';
            if (str != '') {
                str = eval("(" + str + ")");
                str.forEach(item => {
                    html += `
                <a href="javascript:;" class="shList">${item}</a>
            `;
                })
                $('.searchHistoryLists').html(html);
            } else {
                return;
            }
        }

        // 清除历史搜索
        $('.clearSH').on('click', function() {
            // deleteDbData
            if (isAndroid_ios()) {
                //安卓  
                window.android.deleteDbData();
            } else {
                //ios
                window.webkit.messageHandlers.deleteDbData.postMessage('datas');
            }
            getDbDatas();
        })

        let area_id = GetQueryString('area_id');
        // 搜索历史点击录入输入框中
        $(document).on('click', '.searchHistoryLists a', function() {
            $('.heinput').val($(this).html());
            let keys = $(this).html();
            $.ajax({
                type: "post",
                url: url,
                data: { 'method': "Plat|index_search_result", 'keywords': keys, 'area_id': area_id },
                dataType: 'json',
                success: function(res) {
                    // console.log(res);
                    if (res.status == 1) {
                        let company = res.data.company;
                        let ngoods = res.data.ngoods;
                        let goods = '';
                        let com = '';
                        let goodsTitle = '';
                        let comTitle = '';
                        // 更多商品
                        goodsTitle = `
                        <span>商品</span>
                        <a class="moreGoods" href="search_goodsLists_n.html?keys=${keys}&area_id=${area_id}">更多</a>
                    `;
                        $('.goodsTitle').html(goodsTitle);
                        // 更多企业
                        comTitle = `
                        <span>企业</span>
                        <a class="moreCompany" href="more_company_n.html?keys=${keys}&area_id=${area_id}">更多</a>
                    `;
                        $('.comTitle').html(comTitle);

                        if (ngoods.list != '') {
                            ngoods.list.forEach(item => {
                                goods += `
                            <a href="home_n_shopClassifyDetail.html?goods_id=${item.id}&token=${token}" class="shopList">
                                <img src="${item.goods_thumb == '' ? '../img/user.jpg' : item.goods_thumb}" alt="${item.goods_name}">
                                <div class="shopItem">
                                    <p>${item.goods_name}</p>`
                                if (item.price_show_model == 1) {
                                    goods += `<span>¥${item.goods_price}</span>`
                                } else if (item.peice_show_model == 2) {
                                    goods += `<del style="color:#666;font-size:.24rem;">¥${item.price_before}</del>/<span style="font-size:.28rem;">¥${item.goods_price}</span>`
                                } else {
                                    goods += `<span>¥${item.price_area}</span>`
                                }
                                goods += `</div>
                            </a>
                        `;
                            });
                            $('.ngoods').html(goods);
                        } else {
                            $('.ngoods').html(`<p class="marT20" style="text-align:center;color:rgb(128, 128, 128);">未找到相关商品！！！</p>`);
                        }
                        // 企业
                        if (company.list.length != '') {
                            company.list.forEach(item => {
                                com += `
                        <div class="comList">`
                                if (item.company_level >= 1) {
                                    com += `<a href="shop_details_company.html?company_id=${item.id}&token=${token}" class="comHead">`
                                } else {
                                    com += `<a href="shop_details.html?company_id=${item.id}&token=${token}" class="comHead">`
                                }
                                com += `<div class="comHeadLeft">
                                    <img class="headImg" src="${item.company_logo == '' ? '../img/user.jpg' : item.company_logo}" alt="${item.company_name}">
                                    <div class="headlineTopChild">
                                        <p>${item.company_name}</p>`
                                if (item.level_logo != '') {
                                    com += `<img src="${item.level_logo}" class="userLevel"  alt="${item.level_name}"/>`
                                }
                                com += `</div>
                                </div>
                                <p class="comHeadRight">进店</p>
                            </a>
                            <div class="comImgs">`
                                item.goods_list.forEach(g => {
                                    com += `<a href="comp_shopDetail.html?id=${g.id}&token=${token}"><img class="comImg" src="${g.goods_thumb == '' ? '../img/user.jpg' : g.goods_thumb}" alt="${g.goods_name}"></a>`;
                                })
                                com += `</div>
                            <p class="comDesc">
                                主营：${item.main_business}
                            </p>
                            <p class="comAddr">
                                地址：${item.area_name}
                                <span>浏览量${item.read_count}</span>
                            </p>
                        </div>
                        `;
                            })
                            $('.companyList').html(com);
                        } else {
                            $('.companyList').html(`<p class="marT20" style="text-align:center;color:rgb(128, 128, 128);">未找到相关企业！！！</p>`);
                        }
                        $('.searchWrap').hide();
                        $('.serchResultLists').show();
                    } else if (res.status == 2) {
                        location.href = "fox://logout";
                    } else {
                        alert(res.message);
                    }
                }
            })
        })
    </script>
</body>

</html>